package cn.chuanw.db.service;

import cn.chuanw.db.dao.WRoomcostCollectMapper;
import cn.chuanw.db.domain.WRoomcostCollect;
import cn.chuanw.db.domain.WRoomcostCollectExample;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.List;

@Service
public class WRoomCostCollectService {
    @Resource
    private WRoomcostCollectMapper wRoomcostCollectMapper;
   
    public List<WRoomcostCollect> querySelective(String roomId, Integer costType, Integer page, Integer size) {
    	WRoomcostCollectExample wRoomcostCollectExample = new WRoomcostCollectExample();
    	WRoomcostCollectExample.Criteria criteria = wRoomcostCollectExample.createCriteria();

        if (!StringUtils.isEmpty(roomId)) {
            criteria.andRoomIdEqualTo(roomId);
        }
        if (!StringUtils.isEmpty(costType)) {
            criteria.andCostTypeEqualTo(costType);
        }
        criteria.andDelFlagEqualTo(0);
        PageHelper.startPage(page, size);
        return wRoomcostCollectMapper.selectByExample(wRoomcostCollectExample);
    }

    public void addWHouseInfo(WRoomcostCollect wRoomcostCollect) {
    	wRoomcostCollectMapper.insertSelective(wRoomcostCollect);
    }

    public int updateById(WRoomcostCollect wRoomcostCollect) {
        return wRoomcostCollectMapper.updateByPrimaryKeySelective(wRoomcostCollect);
    }

}
